package runnable;

import java.util.concurrent.TimeUnit;

/**
 * @classname:SaleTicket
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/18 23:26
 * @version: 0.1
 * @since:1.8
 */
public class SaleTicketRunnable implements Runnable{
    private Integer ticketNum = 100;


    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if(ticketNum>0){
                System.out.println(Thread.currentThread().getName()+"正在卖第"+(ticketNum--)+"张票");
                try {
                    TimeUnit.MILLISECONDS.sleep(300);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }

    }
}
